package com.clz.appdesign.myapp.ijkplayer;

import android.content.Context;
import android.content.res.Resources;
import android.util.AttributeSet;
import android.util.DisplayMetrics;

import cn.jzvd.JZMediaManager;
import cn.jzvd.JZVideoPlayerStandard;

/**
 * @author chenliangzhi
 * @date 2018/3/30
 * @describe
 */

public class JzVideoView extends JZVideoPlayerStandard {

    public JzVideoView(Context context) {
        super(context);
    }

    public JzVideoView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public void onVideoSizeChanged() {
        if (JZMediaManager.textureView != null) {
            if (videoRotation != 0) {
                JZMediaManager.textureView.setRotation(videoRotation);
            }
            int height = JZMediaManager.textureView.getHeight();
            JZMediaManager.textureView.setVideoSize(getScreenWidth(), height);
        }
    }

    public int getScreenWidth() {
        Resources resources = this.getResources();
        DisplayMetrics dm = resources.getDisplayMetrics();
        int width = dm.widthPixels;
        return width;
    }
}
